// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/Widget.h"
#include "CalendarWidget.generated.h"

class SCalendarWidget;
class SMyComboButton;

//声明了一个响应事件
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnDateUpdata);
/**
 *
 */
UCLASS()
class  UCalendarWidget : public UWidget
{
	GENERATED_BODY()
public:
	UCalendarWidget();

	//设置的属性
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Appearance", meta = (MultiLine = "false", DisplayName = "提示文本"))
		FText HintText;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Appearance", meta = (DisplayName = "字体样式"))
		FTextBlockStyle TextStyle;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Appearance", meta = (DisplayName = "按钮样式"))
		FButtonStyle WidgetStyle;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Appearance", meta = (DisplayName = "图片样式"))
		FSlateBrush SlateBrush;
	//相应的事件
	UPROPERTY(BlueprintAssignable, Category = "Button|Event", meta = (DisplayName = "日期改变时间"))
		FOnDateUpdata OnDateUpdata;

	//暴露给蓝图的设置时间
	UFUNCTION(BlueprintCallable, Category = "Button|Appearance")
		void SetTime(int year, int month, int day);
	//获取时间
	UFUNCTION(BlueprintCallable, Category = "Button|Appearance")
		void GetTime(int &year, int &month, int &day);
	//UMG列表栏
	virtual const FText GetPaletteCategory() ;
	//此控件被销毁后会触发此事件,在这里
	virtual TSharedRef<SWidget> RebuildWidget() override;

	//面板设置完毕后会触发此事件,字面的意思是同步属性
	virtual void SynchronizeProperties() override;
	//资源释放
	virtual void ReleaseSlateResources(bool bReleaseChildren) override;
	//修改日期
	void UpdataCalendar(int year, int month, int day);

public:
	TSharedPtr<SCalendarWidget> PlayCalendar;
	TSharedPtr<SMyComboButton> MyComboButton;
	TSharedPtr<STextBlock> DateText;
	TSharedPtr<SImage> bkImage;
	time_t	CalendarTime;
};
